<?php
$page = 'admin';
require_once 'header.php';
?>

<script>
    jQuery(document).ready(function(){
        jQuery("#update_page_form").validationEngine();
    });
</script>
<?php
include '../database/connect.php';
extract($_GET);
$query = "SELECT * FROM lessons where id='$lesson_id'";
$result = mysql_query($query) or die("Error executing '$query':" . mysql_error());
$row = mysql_fetch_array($result);
$topic = $row['topic'];
$course_id = $row['course'];

//lets get the course name for purpose of navigation
$query = "SELECT * FROM courses where id='$course_id'";
$result = mysql_query($query) or die("Error executing '$query':" . mysql_error());
$row = mysql_fetch_assoc($result);
$course = $row['course'];

$query = "SELECT * FROM lesson_pages where id='$page_id'";
$result = mysql_query($query) or die("Error executing '$query':" . mysql_error());
$row = mysql_fetch_array($result);
$content = $row['content'];
?>


<p>
    <a href="admin_home.php">Admin home</a>&gt;&gt;<a href='courses.php'>Courses</a>&gt;&gt;
    <a href="lessons.php?course_id=<?php echo $course_id; ?>"><?php echo $course; ?></a>&gt;&gt;
    <a href="lessonsContent.php?lesson_id=<?php echo $lesson_id; ?>"><?php echo $topic; ?></a>
</p>

<form action="lessonsContent.php?update=1&lesson_id=<?php echo $lesson_id; ?>&page_id=<?php echo $page_id; ?>" method="post" id="update_page_form"/>
<table>
    <tr>
        <th>
            <?php
            echo 'Topic: ' . $topic;
            ?>
        </th>
    </tr>
    <tr>
        <td><textarea name="content_update" id='content_update' cols="60" rows="17" class="validate[required,minSize[30],maxSize[1000]]"><?php echo $content; ?></textarea></td>
    </tr>
    <tr>
        <td><input type="submit" value="Save Page" />  <input type="button" value="Hide" onclick="hideEditPage();" /></td>
    </tr >
</table>
</form>
<?php require_once 'footer.php'; ?>